package com.mmlc.inter;

import android.content.Context;
import android.widget.BaseAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * @author king
 * @Description: adapter抽象基类
 * @date 2016-6-28 上午9:36:19
 */
public abstract class InterAdapter<T> extends BaseAdapter {

    protected long lasttime = 0;

    protected boolean avoid() {
        return avoid(700);
    }

    protected boolean avoid(long period) {
        long currenttime = System.currentTimeMillis();
        if (currenttime - lasttime <= period) {
            if (context != null) {
            }
            return true;
        } else {
            lasttime = currenttime;
        }
        return false;
    }

    protected List<T> datas;
    protected Context context;
    protected String TAG;
    protected String userId;

    public InterAdapter(Context context, List<T> datas) {
        super();
        this.datas = datas;
        this.context = context;
        TAG = this.getClass().getSimpleName();
        lasttime = System.currentTimeMillis();
    }

    @Override
    public int getCount() {
        return datas.size();
    }

    @Override
    public Object getItem(int position) {
        return datas.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    public void setDatas(ArrayList<T> datas) {
        this.datas = datas;
        notifyDataSetChanged();
    }
}
